<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateTableTeacher extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table  =  $this->table('teacher',array('engine'=>'InnoDB'));
        $table->addColumn('account','char',array('limit' => 11,'comment'=>'登录账号'))
            ->addColumn('password','string',array('limit' => 255,'comment'=>'密码'))
            ->addColumn('truename','string',array('limit' => 20,'default'=>'','comment'=>'真实姓名'))
            ->addColumn('amount','decimal',array('precision'=>5,'scale'=>2,'default'=>'0.00','comment'=>'账户余额'))
            ->addColumn('avatar','string',array('limit' => 100,'default'=>'','comment'=>'用户头像'))
            ->addColumn('gender','boolean',array('limit' => 4,'default'=>1,'comment'=>'1:男,0:女'))
            ->addColumn('birthday','date',array('comment'=>'生日','null'=>false,'default'=>'2000-01-01'))
            ->addColumn('open_id','string',array('limit' => 200,'default'=>'','comment'=>'微信id'))
            ->addColumn('last_login_time','datetime',array('comment'=>'最后登录时间','null'=>false))
            ->addColumn('last_login_ip', 'integer',array('limit'  =>  11,'default'=>0,'comment'=>'最后登录IP'))
            ->addColumn('status','boolean',array('limit' => 4,'default'=>1,'comment'=>'1:启用,0:禁用'))
            ->addColumn('chapter_count','integer',array('limit'=>10,'comment'=>'发布章节数量'))
            ->addColumn('create_time','datetime',array('comment'=>'创建时间'))
            ->addColumn('update_time','datetime',array('comment'=>'修改时间'))
            ->addIndex(array('account'), array('unique'  =>  true))
            ->create();
    }
}
